package javafx.com;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

public class main extends Application {

	public static void main(String[] args) {
		launch(args);
	}

	@Override
	public void start(Stage stage) throws Exception {

		Button button1 = new Button("b1");
		button1.setLayoutX(100);
		button1.setLayoutY(100);
		Button button2 = new Button("b2");
		Button button3 = new Button("b3");
		button3.setLayoutX(100);
		button3.setLayoutY(100);
		Button button4 = new Button("b4");
		
		Group group = new Group();
		group.getChildren().addAll(button3,button4);
		
		// 只能管理孩子,孙子不能管理
		AnchorPane anchorPane = new AnchorPane();
		
		anchorPane.setTopAnchor(group, 200.0);
		anchorPane.setLeftAnchor(group, 200.0);
		
		// 设置内边距,外边距->可以改变节点的大小
//		anchorPane.setPadding(new Insets(10));
//		anchorPane.setTopAnchor(button2, 0.0);
		
//		anchorPane.setTopAnchor(button2, 10.0);
//		anchorPane.setLeftAnchor(button2, 10.0);
//		anchorPane.setRightAnchor(button2, 500.0);
//		anchorPane.setBottomAnchor(button2, 500.0);
		
		anchorPane.getChildren().addAll(button1,button2,group);
		
		anchorPane.setStyle("-fx-background-color:#FF3E96");
		anchorPane.setOnMouseClicked((event) -> {
			System.out.println("ajfhsafj");
		});
		
//		Group group = new Group();
		// 暂未解决的问题-->没有出现效果
//		group.setStyle("-fx-background-color:#FF3E96");
//		group.setOnMouseClicked((event) -> {
//			System.out.println("ajfhsafj");
//		});

//		Scene scene = new Scene(group);
		Scene scene = new Scene(anchorPane);
		
		stage.setScene(scene);
		stage.setTitle("javvfx");
		stage.setWidth(600);
		stage.setHeight(600);

		stage.show();

	}

}
